/**
 * 树点击节点时触发，刷新content主表格
 */
function reloadGrid() {
	var grid = DSYGrid.getGrid('contentGrid');
	var store = grid.getStore();
	//刷新
	store.load();
};  

var q_id;
Ext.onReady(function() {
   var items = [{
                    xtype: 'button',
                    text: '报表维护',
                    icon: '/report/image/sysbutton/edit.png',
                    handler: function (self) {
                    	window.open("/report/page/plat/query/manage/reportManage.jsp", '_blank');
                    }
                },{
                    xtype: 'button',
                    text: '预览',
                    icon: '/report/image/sysbutton/search.png',
                    handler: function (self) {
                    	var record = DSYGrid.getGrid('contentGrid').getCurrentRecord();
                        if (record == null || record == '' || record == 'undefined') {
                            Ext.MessageBox.alert('提示', '请选择一条数据再进行操作');
                            return;
                        }
                        var q_code =  record.get("Q_CODE");
                        var Q_NAME = record.get("Q_TITLE");
                        var yl_url = "/report/page/plat/query/reportQuery.jsp?code="+q_code+"&adcode="+adcode;
                    	window.open(yl_url, '_blank');
                    	//添加日志
                        saveLog('查询报表预览','BUTTON',Q_NAME+'预览');
                    }
                }];
    
    var panel=  new Ext.panel.Panel ({
	    renderTo: Ext.getBody(),
	    height:'100%',
        width:'100%',
	    layout: 'fit',
        defaults: {
            split: true,                  //是否有分割线
            collapsible: false           //是否可以折叠
        },
        border: false,
	    dockedItems: [{
			          xtype: 'toolbar',
			          dock: 'top',//bottom
			          itemId: 'contentPanel_toolbar',
			          items: items
	    			}],
        items: [
                initContentGrid()//初始化用户锁定表格
            ]
        
	});
    
    /**
     * 初始化用户锁定表格
     */
    function initContentGrid() {
    	var headerJson = [{
    		"dataIndex" : "Q_CODE",
    		"type" : "string",
    		"width" : 200,
    		"text" : "报表编码"
    	},{
    		"dataIndex" : "Q_TITLE",
    		"type" : "string",
    		"width" : 200,
    		"text" : "报表名称"
    	},{
    		"dataIndex" : "Q_TABLE_NAME",
    		"type" : "string",
    		"width" : 200,
    		"text" : "数据源"
    	},{
    		"dataIndex" : "MONEY_UNIT_NAME",
    		"type" : "string",
    		"width" : 80,
    		"text" : "金额单位"
    	},{
    		"dataIndex" : "Q_IS_RIGHT_NAME",
    		"type" : "string",
    		"width" : 100,
    		"text" : "是否权限过滤"
    	},{
    		"dataIndex" : "Q_IS_PAGE_NAME",
    		"type" : "string",
    		"width" : 80,
    		"text" : "是否分页"
    	},{
    		"dataIndex" : "Q_IS_SUM_NAME",
    		"type" : "string",
    		"width" : 80,
    		"text" : "是否合计"
    	},{
    		"dataIndex" : "Q_IS_OPENRUN_NAME",
    		"type" : "string",
    		"width" : 120,
    		"text" : "打开方式"
    	},{
    		"dataIndex" : "Q_IS_BUTTON_NAME",
    		"type" : "string",
    		"width" : 130,
    		"text" : "是否显示常用按钮"
    	}];
    	var config = {
                itemId: 'contentGrid',
                border: false,
                flex: 1,
                dataUrl : '/sys-report/getQueryReportList',
                headerConfig: {
                    headerJson: headerJson,
                    columnAutoWidth: false
                },
                checkBox:true,
                pageConfig: {
                    enablePage: false
                },
                rowNumber: {
                    rowNumber: false// 显示行号
                }
    	};
    	var grid = DSYGrid.createGrid(config);
    	return grid;
    }
});
